import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_html/style.dart';
import 'package:text_world/global.dart';

class YiWenCard extends StatefulWidget {
  YiWenCard({Key key, this.yiwen}) : super(key: key);
  final yiwen;
  @override
  _YiWenCardState createState() => _YiWenCardState();
}

class _YiWenCardState extends State<YiWenCard> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      width: MediaQuery.of(context).size.width,
      height: MediaQuery.of(context).size.height,
      color: Global.cardBackgroundColor,
      child: SingleChildScrollView(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            Container(
              width: MediaQuery.of(context).size.width,
              child: FadeInImage.assetNetwork(
                placeholder: 'assets/images/place.jpg',
                fadeInDuration: Duration(milliseconds: 500),
                image: 'https://api.ixiaowai.cn/gqapi/gqapi.php?t=' +
                    DateTime.now().millisecondsSinceEpoch.toString(),
              ),
            ),
            SizedBox(height: 20),
            Container(
              margin: EdgeInsets.only(left: 15),
              child: Text(
                widget.yiwen['title'],
                maxLines: 3,
                style: TextStyle(
                  fontFamily: 'fangzhengkai',
                  fontSize: 19,
                  color: Global.fontColor,
                  fontWeight: FontWeight.w600,
                  height: 1.5,
                ),
              ),
            ),
            Container(
              padding: EdgeInsets.all(10),
              margin: EdgeInsets.all(13),
              decoration: BoxDecoration(
                color: Global.backgroundColor.withOpacity(0.5),
                borderRadius: BorderRadius.circular(3),
              ),
              child: Text(
                '“${widget.yiwen['digest']}”',
                style: TextStyle(
                  fontFamily: 'fangzhengkai',
                  fontSize: 14,
                  color: Global.fontSecondColor,
                  fontWeight: FontWeight.w500,
                ),
              ),
            ),
            Container(
              margin: EdgeInsets.all(12),
              child: Html(
                data: widget.yiwen['content'],
                style: {
                  "p": Style(
                    fontFamily: 'fangzhengkai',
                    color: Global.fontColor,
                    fontWeight: FontWeight.w500,
                    fontSize: FontSize.percent(110),
                  ),
                },
              ),
            ),
            SizedBox(height: 10),
          ],
        ),
      ),
    );
  }
}
